# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pylzma
pkgname=('python2-pylzma' 'python-pylzma')
_pkgname=pylzma
pkgver=0.5.0
pkgrel=10
pkgdesc='Python bindings for the LZMA library.'
arch=('x86_64' 'aarch64')
url='https://pypi.org/project/pylzma/#files'
license=('LGPL-2.1-only')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        "PyTypeObject.patch")
sha512sums=('c4956d84d9e1cbc152c68208acf21f11e6e4ba094b914bf8baeb0522bf8ab7b18dcdbcf114a1b2d1bf29c1cd91808d66c7dd61758686d340ff89cd82fba53ad2'
            'dcdae0215d54cee4906e1b0619da83e39ebdd9f276d46f2f5573ac400b83deb8dc91dbc5a60d160c3ee0705703148d79a3bc7b2fd9b9c0e3b0432708f3a201cb')

prepare() {
  patch -d "$_pkgname-$pkgver" -p1 < PyTypeObject.patch
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pylzma() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

package_python-pylzma() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

